package com.sskj.one.banker;


import com.lzy.okrx2.adapter.FlowableBody;
import com.sskj.common.base.HttpData;
import com.sskj.lib.Constans;
import com.sskj.lib.http.JsonCallBack;
import com.sskj.lib.http.JsonConverter;
import com.sskj.one.bean.DividendListBean;
import com.sskj.one.presenter.BasePresenter;

import java.util.List;

import io.reactivex.Flowable;

/**
 * @author Hey
 * Create at  2019/05/22
 */
class DividendPresenter extends BasePresenter<DividendActivity> {

    public void getData(String type, int page) {
        if (type.equals(Constans.DIVIDEND_HISTORY)) {
            historyDividendt(page);
        } else if (type.equals(Constans.DIVIDEND_TODY)) {
            todayDividendt(page);
        }
    }

    private void todayDividendt(int page) {
        httpService.todayDividendt(page)
                .tag(this)
                .execute(new JsonCallBack<HttpData<List<DividendListBean>>>() {
                    @Override
                    public void onHTTPSuccess(HttpData<List<DividendListBean>> data) {
                        mView.getDataOK(data.getData());
                    }

                    @Override
                    public void onFinish() {
                        super.onFinish();
                        mView.stopRefresh();
                    }
                });
    }

    private void historyDividendt(int page) {
        httpService.historicalDividendt(page)
                .tag(this)
                .execute(new JsonCallBack<HttpData<List<DividendListBean>>>() {
                    @Override
                    public void onHTTPSuccess(HttpData<List<DividendListBean>> data) {
                        mView.getDataOK(data.getData());
                    }

                    @Override
                    public void onFinish() {
                        super.onFinish();
                        mView.stopRefresh();
                    }
                });
    }
}
